#ifndef __ASM_ASSEMBLER_H__
#define __ASM_ASSEMBLER_H__

	.macro	disable_irq_notrace
	cpsid	i
	.endm

	.macro	enable_irq_notrace
	cpsie	i
	.endm

	.macro disable_irq
	disable_irq_notrace
	// asm_trace_hardirqs_off
	.endm

	.macro enable_irq
	// asm_trace_hardirqs_on
	enable_irq_notrace
	.endm

	.macro	csdb
	.inst	0xe320f014
	.endm

	.macro	setmode, mode, reg
	msr	cpsr_c, #\mode
	.endm

#define USER(x...)				\
9999:	x;					\
	.section __ex_table,"a";		\
	.align	3;				\
	.long	9999b,9001f;			\
	.previous

	.macro	usracc, instr, reg, ptr, inc, cond, rept, abort
	.rept	\rept
9999:
	.if	\inc == 1
	\instr\cond\()bt \reg, [\ptr], #\inc
	.elseif	\inc == 4
	\instr\cond\()t \reg, [\ptr], #\inc
	.else
	.error	"Unsupported inc macro argument"
	.endif

	.section __ex_table,"a"
	.align	3
	.long	9999b, \abort
	.previous
	.endr
	.endm

	.macro	ldrusr, reg, ptr, inc, cond=al, rept=1, abort=9001f
	usracc	ldr, \reg, \ptr, \inc, \cond, \rept, \abort
	.endm

#endif
